package com.lma.action;

import java.awt.image.BufferedImage;

import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.ServletActionContext;
import org.apache.struts2.dispatcher.StrutsResultSupport;

import com.opensymphony.xwork2.ActionInvocation;

import cn.dsna.util.images.ValidateCode;

public class CaptchaAction extends StrutsResultSupport {

	@Override
	protected void doExecute(String finalLocation, ActionInvocation invocation) throws Exception {
		//生成随机验证码
		ValidateCode vc = new ValidateCode(100, 100, 4, 200);
		BufferedImage image = vc.getBuffImg();
		HttpServletResponse response = ServletActionContext.getResponse();
		
		ImageIO.write(image, "jpeg", response.getOutputStream());
	}

}
